package colicious.web;

import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import colicious.service.Login;


public class LoginFormController extends SimpleFormController {

	/** Logger for this class and subclasses */
	
	protected final Log logger = LogFactory.getLog(getClass());
	
	public ModelAndView onSubmit(Object command) throws ServletException {
		String li = ((Login) command).getLogin();
		String pw = ((Login) command).getPassword();
		
		logger.info("Updating " + li + " / " + pw);
		logger.info("returning from PriceIncreaseForm view to " + getSuccessView());
		
		return new ModelAndView(new RedirectView(getSuccessView()));
	}

	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
		Login Login = new Login();
		Login.setLogin("test");
		Login.setPassword("test");
		return Login;
	}
}
